package com.haven123.cloudapp.websocket;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 *  启动顺序测试
 */
@Slf4j
@Component
public class Init implements InitializingBean, ApplicationContextAware {
//    @Value("${config-server}")
//    private String configserver;
    @Autowired
    private Environment environment;
    @PostConstruct
    public void postConstruct(){
        final String configserver = environment.getProperty("form");
        log.info("这里是: postConstruct {}",configserver);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        final String configserver = environment.getProperty("config-server");
        log.info("这里是: initializingBean afterpropertiesSet {}",configserver);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        final String configserver = environment.getProperty("config-server");
            log.info("这里是: applicationContextAware {}",configserver);
    }
}
